<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
	<th:block th:include="include :: header('隐患表单')" />
	<link rel="stylesheet" href="/libs/mui/css/mui.min.css">
	<link rel="stylesheet" type="text/css" href="/libs/mui/css/app.css" />
	<link rel="stylesheet" type="text/css" href="/libs/mui/css/mui.picker.min.css" />
	<link rel="stylesheet" type="text/css" href="/common/css/form.css">
	<link  rel="stylesheet" type="text/css"  href="/libs/webuploader/webuploader.css"/>
</head>
<body class="up_body">
<div class="mui-content up_form_content">
	<!--表单start-->
	<form class="mui-input-group up_group" id="form">
		<div class="up_gray"></div>
		<div class="up_gray"></div>

		<input th:value="${details.ID}" type="hidden" class="id" name="ID">
		<!--<input th:value="${details.Status}" type="hidden" class="Status" name="Status">-->

		<div class="up_row">
			<label><font>*</font>检查单位</label>
			<input type="text" th:value="${details.DiscoverUserNames}" id="deptName" readonly>
			<input type="hidden" th:value="${details.CreateOrganizationID}" name="CreateOrganizationID">
			<div class="clear_both"></div>
		</div>
		<div class="up_row">
			<label><font>*</font>检查人：</label>
			<input type="text" th:value="${details.DiscoverUserNames}" id="userName" readonly>
			<input type="hidden" th:value="${details.DiscoverUserIDs}" name="DiscoverUserIDs">
			<div class="clear_both"></div>
		</div>
		<div class="up_gray"></div>
		<div class="up_row">
			<label><font>*</font>检查时间</label>
			<input type="hidden" th:value="${details.FindDate}" name="FindDate-">
			<input type="text" class="date-select icon_more"  placeholder="请选择时间" id="FindDateShow" th:value="${details.FindDate}" name="FindDate"  readonly>
			<input type="hidden" th:value="${details.FindDate}" id="FindDate">
			<div class="clear_both"></div>
		</div>
		<div class="up_row record-select" th:data="${@dict.getTypeByJson('HIHiddenDangerTypes')}">
			<label><font>*</font>隐患类型</label>
			<input type="text" class="record-select-data icon_more" placeholder="请选择" th:value="${details.HIHiddenDangerTypeName}" readonly>
			<input type="hidden" class="record-select-id" th:value="${details.HIHiddenDangerTypeID}" name="HIHiddenDangerTypeID">
			<icon class="icon_more fright"></icon>
			<div class="clear_both"></div>
		</div>
		<div class="up_row record-select" th:data="${@dict.getTypeByJson('HIHiddenDangerLevels')}">
			<label><font>*</font>隐患等级</label>
			<input type="text" class="record-select-data icon_more" placeholder="请选择" th:value="${details.HIHiddenDangerLevelName}" readonly>
			<input type="hidden" class="record-select-id" th:value="${details.HIHiddenDangerLevelID}" name="HIHiddenDangerLevelID">
			<icon class="icon_more fright"></icon>
			<div class="clear_both"></div>
		</div>
		<div class="up_row">
			<label><font>*</font>整改期限</label>
			<input type="text" class="date-select icon_more" placeholder="请选择时间" id="DeadLineShow" th:value="${details.DeadLine}" name="DeadLine"  readonly>
			<input type="hidden" th:value="${details.DeadLine}" id="DeadLine">
			<icon class="icon_more fright"></icon>
			<div class="clear_both"></div>
		</div>
		<div class="up_row">
			<label><font>*</font>责任单位</label>
			<input type="hidden" name="ResOrganizationID" th:value="${details.ResOrganizationID}" />
			<input type="text" class="icon_more" th:value="${details.ResOrganizationName}" onclick="selectDeptTree(this)" name="ignore5" bind-name="ResOrganizationID" placeholder="请选择" id="treeName"  required>
			<icon class="icon_more fright"></icon>
			<div class="clear_both"></div>
		</div>

		<div class="up_row">
			<label><font>*</font>整改责任人</label>
			<input type="hidden" name="ResUserID" th:value="${details.ResUserID}"/>
			<input type="text" class="icon_more" th:value="${details.ResUserName}" onclick="selectUserTree(this)" name="ignore6" bind-name="ResUserID" placeholder="请选择" id="ResUserName"  required>
			<icon class="icon_more fright"></icon>
			<div class="clear_both"></div>
		</div>

		<div class="up_row" th:if="${isLeader == false}">
			<label><font>*</font>复查人</label>
			<input type="hidden" name="Status" th:value="2">
			<input type="hidden" name="ReviewUserID" th:value="${details.ReviewUserID}"/>
			<input type="text" class="icon_more" th:value="${details.ReviewUserName}" onclick="selectUserTree(this)" name="ignore7" bind-name="ReviewUserID" placeholder="请选择" id="ReviewUserName"  required>
			<div class="clear_both"></div>
		</div>
		<div class="up_row"  th:if="${isLeader == true}">
			<label><font>*</font>审核人</label>
			<input type="hidden" name="Status" th:value="1">
			<input type="hidden" name="FirstUserID" th:value="${details.FirstUserID}"/>
			<input type="text" class="icon_more" th:value="${details.FirstUserName}" onclick="selectUserTree(this)" name="ignore8" bind-name="FirstUserID" placeholder="请选择" id="FirstUserName"  required>
			<div class="clear_both"></div>
		</div>

		<!--<div class="mui-input-row up_row up_file_list" th:if="${isLeader == false}">-->
			<!--<label><font>*</font>复查人</label>-->
			<!--<input type="hidden" name="ReviewUserID"/>-->
			<!--<div class="up_file_right">-->
				<!--<div class="up_file"></div>-->
				<!--<div class="clear_both"></div>-->
				<!--<div class="up_file_tj"></div>-->
				<!--<div></div>-->
			<!--</div>-->
			<!--<div class="clear_both"></div>-->
		<!--</div>-->
		<!--<div class="mui-input-row up_row up_file_list"  th:if="${isLeader == true}">-->
			<!--<label><font>*</font>审核人</label>-->
			<!--<input type="hidden" name="FirstUserID"/>-->
			<!--<div class="up_file_right">-->
				<!--<div class="up_file"></div>-->
				<!--<div class="clear_both"></div>-->
				<!--<div class="up_file_tj"></div>-->
				<!--<div></div>-->
			<!--</div>-->
			<!--<div class="clear_both"></div>-->
		<!--</div>-->
		<div id="filePicker" class="up_file_img"></div>
		<div class="mui-input-row up_row up_file_list up_fileimg_list">
			<input type="hidden" id="imageIds" th:each="attachment,index : ${details.CreateAttachment}" th:value="${attachment.ID}" name="CreateAttachment"/>
			<label><font></font>隐患附件</label>
			<div class="clear_both"></div>
			<div class="up_fileimg_right">
				<div id="preview"></div>
				<div id="WU_FILE_" class="file-item thumbnail" th:each="attachment,index : ${details.CreateAttachment}" th:data="${attachment.ID}">
					<img th:each="attachment,index : ${details.CreateAttachment}" th:src="${attachment.Path}">
					<span class="file_close"></span>
				</div>

				<div class="clear_both"></div>
				<div></div>
			</div>
			<div class="clear_both"></div>
		</div>
		<div class="up_gray"></div>
		<div class="up_row">
			<label><font>*</font>隐患内容</label>
			<textarea rows="5" placeholder="请输入隐患内容" name="HDName" th:text="${details.HDName}"></textarea>
		</div>
		<div class="up_row">
			<label><font>*</font>隐患地点</label>
			<textarea rows="5" placeholder="请输入隐患内容" name="HDPlace" th:text="${details.HDPlace}"></textarea>
		</div>
		<div class="up_row">
			<label><font>*</font>整改要求</label>
			<textarea rows="5" placeholder="请输入整改要求" name="RectificationRequest" th:text="${details.RectificationRequest}"></textarea>
		</div>
		<div class="up_gray"></div>
		<!--表单end-->
		<div class="up_button">
			<input type="button" id="submit" class="up_button_left" value="提交" />
			<input type="button" class="up_button_right" value="保存" /></div>
		<div class="clear_both"></div>
	</form>
</div>
</body>
<th:block th:include="include :: footer" />
<script src="/libs/mui/js/mui.min.js"></script>
<script src="/libs/mui/js/mui.picker.min.js"></script>
<script src="/libs/webuploader/webuploader.nolog.js"></script>
<script src="/common/js/form.js"></script>
<script>
	//回显内容
	$("#deptName").val($.userOperate.deptName());
	$("#userName").val($.userOperate.userName());
	$("[name=CreateOrganizationID]").val($.userOperate.deptId());
	$("[name=CreateUserID]").val($.userOperate.userId());

	//提交
	$(".up_button_left").click(function(){
        console.log($.common.serializeNotNull()+"&entityName=HIHiddenDanger&opName=Apply&userId="+$.userOperate.userId());
        var data = $("form").serialize()+"&entityName=HIHiddenDanger&opName=Apply&userId="+$.userOperate.userId();
		$.ajax({
			url:ctx+"/public/Save",
			type:"post",
			data:data,
			dataType:"json",
			success:function (obj) {
			    if(obj.statusCode==0){
					location.href = "/hidden/list?userId="+$.userOperate.userId();
				}else{
			        alert(obj.statusMsg);
				}
            }
		})
	});
    //保存*
    $(".up_button_right").click(function(){
        $("[name=Status]").val("0");
        if ($.validate.form()) {
            $.ajax({
                async:false,
                url:ctx+"/public/Save",
                type:"post",
                data:$("form").serialize()+"&entityName=HIHiddenDanger&opName=Edit&userId="+$.userOperate.userId(),
                dataType:"json",
                success:function (obj) {
                    if(obj.statusCode==0){
                        location.href = "/hidden/list?userId="+$.userOperate.userId();
                    }else{
                        alert(obj.statusMsg);
                    }
                }
            })
        }
    });

    // 初始化Web Uploader
    var uploader = WebUploader.create({
        // 选完文件后，是否自动上传。
        auto: true,

        // 文件接收服务端。
        server: ctx + '/public/UpoladFiles',

        // 选择文件的按钮。可选。
        // 内部根据当前运行是创建，可能是input元素，也可能是flash.
        pick: '#filePicker',

        // 只允许选择图片文件。
        accept: {
            title: 'Images',
            extensions: 'gif,jpg,jpeg,bmp,png',
            mimeTypes: 'image/*'
        }
    });
    //初始化图片上传 事件
    uploaderInit(uploader);
    //删除图片
    $(document).on("click",".file_close",function(){
        var fileDiv = $(this).parent();
        var fileId = fileDiv.attr("id");
        var imageIds = $("#imageIds").val();
        $("#imageIds").val(imagesIdsReplace(imageIds,fileDiv));
        fileDiv.remove();
        uploader.removeFile(fileId);
    });
</script>
</html>
